<?php

class M_discount_labels Extends MY_Model
{
	public function get_labels($id=FALSE)
	{
		if($id)
		{
			$sql = "SELECT *
					FROM discount_labels
					WHERE id = ?
					";
						
			$query = $this->db->query($sql,array($id));		
													 
			return $query-> num_rows() >= 1 ? $query->row() : FALSE;
		}else{
			$sql = "SELECT *
					FROM discount_labels
					";
						
			$query = $this->db->query($sql);		
													 
			return $query-> num_rows() >= 1 ? $query->result() : FALSE;
		}
	}
	
	public function add_discount_label($data=FALSE)
	{
		if($data)
		{
			$this->db->insert('discount_labels', $data); 
			return $this->db->affected_rows()>0 ? TRUE : FALSE;
		}
	}
	
	public function update_discount_label($id=FALSE,$data=FALSE)
	{
		if($id && $data)
		{
			
			$this->db->where('id', $id);
			$this->db->update('discount_labels', $data);
			return $this->db->affected_rows()>0 ? TRUE : FALSE;
		}
	}
	
	public function delete_discount_label($id=FALSE)
	{
		if($id)
		{
			$this->db->delete('discount_labels', array('id' => $id)); 
			return $this->db->affected_rows()>0 ? TRUE : FALSE;
		}
	}
}